import config from '../../config/env'

Component({
  data: {
    user: {}
  },
  pageLifetimes: {
    show() {
      if (typeof this.getTabBar === 'function' &&
        this.getTabBar()) {
        this.getTabBar().setData({
          selected: 2
        })
      }

      // 会返回，还是放这里
      const user = wx.getStorageSync('user')
      if (!user.avatar) {
        user.avatar = config.DEFAULT_IMAGE_URL
      }
      this.setData({
        user,
      })
    }
  },
  methods: {
    onReachBottom: function () {
      wx.showToast({
        icon: "none",
        title: '下拉触底',
      })
    },
    toNickname() {
      wx.navigateTo({
        url: '/pages/nickname/index',
      })
    },
    toCollect() {
      wx.navigateTo({
        url: '/pages/collect/index',
      })
    },
    toLike() {
      wx.navigateTo({
        url: '/pages/like/index',
      })
    },
    toRobot() {
      wx.navigateTo({
        url: '/pages/robot-list/index',
      })
    }
  },
  attached() {

  }
})